#!/bin/bash
###
# @Author: Logan.Li
# @Gitee: https://gitee.com/attacker
# @email: admin@attacker.club
# @Date: 2022-11-10 14:19:49
# @LastEditTime: 2023-12-06 15:48:09
# @Description:
###
# curl  -s http://wuyou.run/services/python3.9.sh|bash

if [ -f /usr/bin/python3 ]; then
    echo "检测到python3已安装"
else
    yum install python3-devel python3-ldap openldap-devel openssl-devel \
        libffi-devel libxml2-devel libxslt-devel \
        bzip2-devel expat-devel bzip2-devel readline-devel \
        libjpeg-devel libpng-devel libtiff-devel libwebp-devel -y
    if [ ! -f Python-3.* ]; then
        wget -c https://www.python.org/ftp/python/3.9.17/Python-3.9.17.tar.xz
        if [ $? != 0 ]; then
            echo "下载失败 !!!"
            exit 1
        fi
    fi

    tar xf Python*xz
    cd Python-3.*
    ./configure --prefix=/usr/local/python3.9
    make -j2
    make altinstall
    # altinstall在安装时会区分已存在的版本

    rm /usr/local/python3.9 /usr/bin/python3 -rf
    ln -s /usr/local/python3.9/bin/python3.9 /usr/bin/python3
    ln -s /usr/local/python3.9/bin/python3.9 /usr/local/bin/
    ln -s /usr/local/python3.9/bin/python3.9 /usr/local/bin/python3
    ln -s /usr/local/python3.9/bin/pip3.9 /usr/local/bin/
    cd ..
fi

*
